package com.lichuang.dedao.city.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lichuang.dedao.city.entity.Note;
import com.lichuang.dedao.city.entity.User;
import com.lichuang.dedao.city.fingnclient.UserFeignClient;
import com.lichuang.dedao.city.mapper.NoteMapper;
import com.lichuang.dedao.city.service.impl.NoteServiceImpl;
import org.aspectj.weaver.Lint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;

/**
 * <p>
 * 笔记 前端控制器
 * </p>
 *
 * @author wp
 * @since 2019-07-13
 */
@RestController
@RequestMapping("//note")
@CrossOrigin("http://127.0.0.1:8020")
public class NoteController {

    @Autowired
    NoteMapper noteMapper;


    @Autowired
    NoteServiceImpl noteService;

    /**
     * 查询所有笔记
     * @param loginToken
     * @return
     */
    @RequestMapping("selAllNote")
    public List<Note> selAllNote(@CookieValue("loginToken") String loginToken){
        List<Note> list = noteService.selAllNote(loginToken);
        return list;
    }


    @Autowired
    FileController fileController;


    /**
     * 插入笔记 转发/新增
     * @param note
     * @return
     */
    @RequestMapping("/insNote")
    public int insNote(Note note,String source,String destination){
        fileController.file(source,destination);
        return noteService.instranspond(note);
    }


    /**
     * 更新点赞数
     * @param notr_id
     * @param
     * @return
     */
    @RequestMapping("/updlike")
    public int updlike(Integer uid,Integer notr_id){
        return noteService.updlike(uid,notr_id);
    }


}
